<?php
namespace Admin\Controller;

use Admin\Util\lib\API;
use Admin\Util\lib\YZTokenClient;
use Util\AccessController;
use Admin\Util\lib\YouZanApiFunction;

class BookTZController extends AccessController {


    public function Index() {
        $LS = Service('M','book_tz_view');
        $count = $LS->count();
        $Page = new \Think\NewPage($count, 5);
        $show = $Page->show(); // 分页显示输出
        $limit = $Page->limit();
        $this->show  = $show;
        $order =I('get.order') != '' && I('get.sort') != ''?PageSort(I('get.order'),I('get.sort')):'';
        $where =array();
        $files = '*';
        $DATA = $LS->query($where, $limit, $files, $order);
        $this->data  = $DATA;
        $this->display();
    }
    /*
     * 到货通知
     */
    public function BookTZ(){
        $where = array('tz_ID'=>$_POST['ID']);
        $LS =Service('M','book_tz_view');
        $DATA =$LS->find($where);
        $LS1 = Service('M','u_user');
        $user = $LS1->find(array('user_id'=>$DATA['tz_OPENID']));
        $Send = A('Admin/WxSendMsg');
        $OK = $Send->Book_TZ_SendMsg($DATA['b_ID'],$DATA['b_TITLE'],$user['user_wx']);
        if($OK ==0){
            $where1['ID'] = $_POST['ID'];
            $LS1=Service('M','book_tz');
            $OK1 = $LS1->Del($where1);
            echo $OK1;
        }else{
            echo -1;
        }
    }




}